package com.heima.wemedia;

import com.heima.file.service.FileStorageService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

@SpringBootTest
@RunWith(SpringRunner.class)
public class OssUpload {
    @Autowired
    FileStorageService fileStorageService;

    @Value("${file.oss.web-site}")
    String webSite;

    @Test
    public void upload() throws FileNotFoundException {
        FileInputStream inputStream = new FileInputStream("C:\\Users\\王鹏军\\Pictures\\图片\\优芙得.jpg");
        String store = fileStorageService.store("material", "yfd.jpj", inputStream);
        System.out.println(webSite + store);
        fileStorageService.delete("material/2021/9/20210923/yfd.jpj");
    }
}
